# -*- coding: utf-8 -*-
from sqlalchemy import Column,String,Integer,Text,Binary,Boolean,DateTime,Enum,Float,BigInteger
from adminApp.extensions import db
from .base import BaseModel
import uuid


def gen_id():
    return uuid.uuid4().hex


class AqyBandWidth95(BaseModel, db.Model):
    '''带宽速率95计费提取点 5分钟提取一个点'''
    # Unix,BytesSent,BytesReceived,MaxConn,ActiveOpens,PassiveOpens,CurrEstab,InErrs,InCsumErrors,KCPInErrors,InPkts,OutPkts,InSegs,OutSegs,InBytes,OutBytes,RetransSegs,FastRetransSegs,EarlyRetransSegs,LostSegs,RepeatSegs,FECParityShards,FECErrs,FECRecovered,FECShortShards
    # 2020-11-07_12:28:47,8054930,0,0,0,0,0,0,0,0,0,0,0,0,0,11673454,0,0,0,0,0,0,0,0,0
    Unix = Column(String(64))   # 2020-11-07_12:28:47
    MbpsSent = Column(BigInteger)
    MbpsReceived = Column(BigInteger)
    Unix_time = Column(DateTime, index=True)

    machine_id = db.Column(db.Integer, db.ForeignKey('machine.id', ondelete='CASCADE'), nullable=False, index=True)
    machine = db.relationship('Machine', back_populates='aqyBandWidth95s')

    __table_args__ = (
        #db.Index('ix_machineid_nictime', "machine_id", "Unix"),
        db.Index('ix_machineid_Unix_time', "machine_id", "Unix_time"),
        # db.UniqueConstraint('domain_id', 'book_mark', name='uix_domain_bookmark')
    )